<template>
	<view class="content padding">
		<!-- <u-sticky bgColor="#fff">
			<u-tabs :list="list1" lineColor="rgba(243, 39, 28, 1)" :current="currenttabtow" :scrollable="false" @click="clicktabtow"
				:activeStyle="{
				    color: '#000000',
				    fontWeight: 'bold',
				    transform: 'scale(1.05)'
				}" :inactiveStyle="{
				            color: 'rgba(102, 102, 102, 1)',
							fontWeight: 'bold',
				            transform: 'scale(1)'
				        }" itemStyle="padding-left: 15px; padding-right: 15px; height: 44px;"></u-tabs>
		</u-sticky> -->
		<view class="">
			<view class="ffffff padding border_2 margin_bottom3" v-for="(item,index) in list.data" :key="item.id"
				@click="goOrderInfo(item.id)">
				<view class="flexbetween">
					<view class="color_ling text_z margin_right1">{{item.refund_no}}</view>
					<!-- 状态 -->
					<view class="hongsetext" style="color: rgba(255, 138, 2, 1)" v-show="item.checkinfo_type==10">待审核</view>
					<view class="hongsetext" style="color: #5cb85c;" v-show="item.checkinfo_type==20">已通过</view>
					<view class="hongsetext" style="color: rgba(243, 39, 28, 1)" v-show="item.checkinfo_type==30">已拒绝</view>
					<view class="hongsetext" style="color: #5cb85c;" v-show="item.checkinfo_type==40">已取消</view>
					<view class="hongsetext" style="color: #5cb85c;" v-show="item.checkinfo_type==50">退款成功</view>
				</view>
				<view class="flexbetween xiahuax margin_top" v-for="(ite,index1) in item.refundgoods" :key="ite.id">
					<view class="shilitu">
						<image :src="ite.ordergoods.goods_image_text" mode=""></image>
					</view>
					<view class="" style="width: 74%;">
						<view class="yihang text_zi">{{ite.ordergoods.goods_name}}</view>
						<view class="baise">{{ite.ordergoods.sku}}</view>
						<view class="flexbetween">
							<view class="qianshu">¥{{ite.ordergoods.pay_price}}</view>
							<view class="shuliang">X{{ite.ordergoods.goods_num}}</view>
						</view>
					</view>
				</view>
				<!-- 所有按钮 -->
				<view class="flexright margin_top">
					<view class="huisebtn" @click.stop="goLogisticsInfo(item.id)" v-show="item.can_express">查看物流</view>
					<view class="huangsebtn margin_left3" v-show="item.can_refuse" @click.stop="refundReturn(item.id)">拒绝申请
					</view>
					<view class="huangsebtn margin_left3" v-show="item.can_agree" @click.stop="sureReturn(item.id)">同意申请
					</view>
					<view class="huangsebtn margin_left3" v-show="item.can_receipt" @click.stop="sureShouhuo(item.id)">确认收货</view>
				</view>
			</view>
			<view class="flexcenter placeholderBoxTop" v-if="!list.data.length">
				<image class="placeholderBox" src="/static/placeholderimg.png" mode=""></image>
			</view>
		</view>
		<!-- 拒绝退款 -->
		<u-modal :show="modalshow" title="拒绝退款" showCancelButton confirmColor="#f12a1f" @cancel="confirmReturn" @confirm="confirmReturn(1)">
			<view class="slot-content">
				<input type="text" placeholder="请输入拒绝原因" style="text-align: center;" v-model="error_reason">
			</view>
		</u-modal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				columns: [],
				currenttabtow: 0, //0全部，1待发货，2待收货，3待取货，4已完成
				// list1: [{
				// 		name: '待处理',
				// 	},
				// 	{
				// 		name: '退货中',
				// 	},
				// 	{
				// 		name: '已退款',
				// 	}
				// ],
				page: 1,
				list: {
					data: []
				},
				orderDetail: {}, // 订单详情内容
				modalshow:false,
				error_reason:"",
				tkid:"",
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				httpRequest.request("/api/shop.goods_refund/getlist", 'GET', {
					page: page || 1,
					state: 0,
				}, false, false, true).then(res => { //我的订单接口
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							_this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page)
			},
			goLogisticsInfo(id) { //查看物流
				uni.navigateTo({
					url: "/pages_mine/logisticsInfo?type=2&id="+id
				})
			},
			// 确认收货
			sureShouhuo(id){
				httpRequest.modal('提示', '确定收到货了吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/shop.goods_refund/receipt', 'POST', {
							order_refund_id: id,
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg);
							if (res.code == 1) {
								this.init()
							}
						}).catch(err => {
							httpRequest.toast(err.msg);
						})
					}
				})
			},
			sureReturn(id) {
				httpRequest.modal('提示', '确定同意申请吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/shop.goods_refund/agree', 'POST', {
							order_refund_id: id,
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg);
							if (res.code == 1) {
								this.init()
							}
						}).catch(err => {
							httpRequest.toast(err.msg);
						})
					}
				})
			},
			refundReturn(id) {
				this.tkid = id
				this.modalshow = true
			
			},
			confirmReturn(value){
				if(value==1){
					if(this.error_reason==""){
						httpRequest.toast("请输入拒绝申请的原因")
						return false
					}
					httpRequest.request('/api/shop.goods_refund/refuse', 'POST', {
						order_refund_id: this.tkid,
						error_reason:this.error_reason
					}, false, false, true).then(res => {
						httpRequest.toast(res.msg);
						if (res.code == 1) {
							this.init()
						}
					}).catch(err => {
						httpRequest.toast(err.msg);
					})
					this.modalshow = false
					this.error_reason = ""
				}else{
					this.modalshow = false
					this.error_reason = ""
				}
				
			},
			goOrderInfo(id) { //订单详情
				uni.navigateTo({
					url: "/pages_mine/refundOrderInfo?id=" + id
				})
			},
			clicktabtow(e) {
				this.currenttabtow = e.index;
				this.init()
			},
		}
	}
</script>

<style lang="scss" scoped>
	// ::v-deep.u-tabs__wrapper__nav__item {
	// 	//平均分配
	// 	flex: 1;
	// }
	.imgShop {
		width: 26.62rpx;
		height: 24rpx;

	}

	.fuzhi {
		margin: 0rpx 30rpx 30rpx 30rpx;
	}

	.dan {
		width: 80vw;
		padding: 64rpx 40rpx 0rpx 40rpx;
	}

	.wuliu {
		font-size: 40rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	.zhongtong {

		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
		padding: 34rpx 82rpx;
		border: 1rpx solid rgba(223, 223, 223, 1);
		border-radius: 10rpx;
		margin: 87rpx 0rpx 0rpx 0rpx;
	}

	.copy {
		padding: 25rpx 150rpx;
		border-radius: 51rpx;
		background-color: RGBA(225, 159, 83, 1);
		margin-top: 109rpx;
		color: #fff;
	}

	.text_zi {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.number {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	.nostrongtext {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.baise {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
		margin: 12rpx 0rpx;
	}

	.huangsebtn {
		border: 2rpx solid rgba(243, 39, 28, 1);
		width: 170rpx;
		height: 67rpx;
		display: flex;
		border-radius: 120rpx;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(243, 39, 28, 1);
	}

	.huisebtn {
		border: 2rpx solid #666666;
		width: 170rpx;
		height: 67rpx;
		display: flex;
		border-radius: 120rpx;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.ershisi {
		font-size: 30rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 800;
		color: rgba(243, 39, 28, 1);
	}

	.xiahuax {
		padding-bottom: 30rpx;
		border-bottom: 1rpx solid rgba(153, 153, 153, .1);
	}

	.shuliang {
		font-size: 26rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: rgba(243, 39, 28, 1);
	}

	.qianshu {
		font-size: 30rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color: rgba(243, 39, 28, 1);
	}

	.ershib {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.shilitu {
		width: 134rpx;
		height: 128rpx;
		border-radius: 14rpx;

		image {
			width: 100%;
			height: 100%;
			border-radius: 14rpx;
		}
	}

	.lvsetext {
		font-size: 24rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #00C058;
	}

	.huangsetext {
		font-size: 24rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: RGBA(255, 117, 16, 1);
	}

	.hongsetext {
		font-size: 24rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: RGBA(255, 117, 16, 1);
	}

	.marginleft3 {
		margin-left: 30rpx;
	}
</style>